/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bean.timer.editors;

import com.bean.timer.interfaces.TimerButtonIcon;
import java.beans.PropertyEditorSupport;
import java.util.Arrays;

/**
 *
 * @author Lukasz
 */
public class TimerButtonIconEditor extends PropertyEditorSupport{
    
    private String[] tags = {"Start", "Stop", "Reset"};
    
    @Override
    public String getAsText(){
        int index = ((TimerButtonIcon) getValue()).ordinal();
        return tags[index];
    }
    @Override
    public void setAsText(String text){
        int index = Arrays.asList(tags).indexOf(text);
        if(index >= 0) setValue(TimerButtonIcon.values()[index]);
    }
    
    @Override
    public String[] getTags(){
        return tags;
    }
    
    @Override
    public String getJavaInitializationString() {
        return TimerButtonIcon.class.getName()+"." +getValue();
    }
}
